<!DOCTYPE html>






  


<html class="theme-next mist use-motion" lang="zh-CN">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2"/>
<meta name="theme-color" content="#222">



  
  
  <link rel="stylesheet" href="/lib/needsharebutton/needsharebutton.css">




  
  
    
    
  <script src="/lib/pace/pace.min.js?v=1.0.2"></script>
  <link href="/lib/pace/pace-theme-minimal.min.css?v=1.0.2" rel="stylesheet">







<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />










  <meta name="baidu-site-verification" content="6hi01gkdPQ" />










  
  
  
  

  
    
    
  

  
    
      
    

    
  

  

  
    
      
    

    
  

  
    
      
    

    
  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Monda:300,300italic,400,400italic,700,700italic|Roboto Slab:300,300italic,400,400italic,700,700italic|Lobster Two:300,300italic,400,400italic,700,700italic|PT Mono:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=6.2.0" rel="stylesheet" type="text/css" />


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.ico?v=6.2.0">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.ico?v=6.2.0">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.ico?v=6.2.0">


  <link rel="mask-icon" href="/images/logo.ico?v=6.2.0" color="#222">









<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Mist',
    version: '6.2.0',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: false,
    fastclick: false,
    lazyload: false,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    algolia: {
      applicationID: '995B6MOVEJ',
      apiKey: 'cc928ef862522d7631d991ac65f2ec92',
      indexName: 'imwangyu',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>


  




  <meta name="description" content="sql语句相关使用having过滤分组，使用where过滤行数据。集合操作使用having不使用where %匹配0个或多个，_匹配单个 and 优先级大于 or UNION并  MINUS差 INTERSECT交 MYSQL不支持 UNION 内部的 SELECT 语句必须拥有相同数量的列。列也必须拥有相似的数据类型。同时，每条 SELECT 语句中的列的顺序必须相同。 允许重复 UNION A">
<meta name="keywords" content="知识点,MySQL">
<meta property="og:type" content="article">
<meta property="og:title" content="MySQL相关知识点">
<meta property="og:url" content="http://wyu.space/2018/05/02/MySQL相关知识点/index.html">
<meta property="og:site_name" content="Sometimes Naive">
<meta property="og:description" content="sql语句相关使用having过滤分组，使用where过滤行数据。集合操作使用having不使用where %匹配0个或多个，_匹配单个 and 优先级大于 or UNION并  MINUS差 INTERSECT交 MYSQL不支持 UNION 内部的 SELECT 语句必须拥有相同数量的列。列也必须拥有相似的数据类型。同时，每条 SELECT 语句中的列的顺序必须相同。 允许重复 UNION A">
<meta property="og:locale" content="zh-CN">
<meta property="og:updated_time" content="2018-05-02T15:36:38.930Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="MySQL相关知识点">
<meta name="twitter:description" content="sql语句相关使用having过滤分组，使用where过滤行数据。集合操作使用having不使用where %匹配0个或多个，_匹配单个 and 优先级大于 or UNION并  MINUS差 INTERSECT交 MYSQL不支持 UNION 内部的 SELECT 语句必须拥有相同数量的列。列也必须拥有相似的数据类型。同时，每条 SELECT 语句中的列的顺序必须相同。 允许重复 UNION A">



  <link rel="alternate" href="/atom.xml" title="Sometimes Naive" type="application/atom+xml" />




  <link rel="canonical" href="http://wyu.space/2018/05/02/MySQL相关知识点/"/>



<script type="text/javascript" id="page.configurations">
  CONFIG.page = {
    sidebar: "",
  };
</script>

  <title>MySQL相关知识点 | Sometimes Naive</title>
  






  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?405d001d8bd35d058cc9251901c71aa6";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>




  <noscript>
  <style type="text/css">
    .use-motion .motion-element,
    .use-motion .brand,
    .use-motion .menu-item,
    .sidebar-inner,
    .use-motion .post-block,
    .use-motion .pagination,
    .use-motion .comments,
    .use-motion .post-header,
    .use-motion .post-body,
    .use-motion .collection-title { opacity: initial; }

    .use-motion .logo,
    .use-motion .site-title,
    .use-motion .site-subtitle {
      opacity: initial;
      top: initial;
    }

    .use-motion {
      .logo-line-before i { left: initial; }
      .logo-line-after i { right: initial; }
    }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-CN">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>
	
	<a href="https://github.com/imwangyu"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub"></a>
	
    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">Sometimes Naive</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle"></p>
      
  </div>

  <div class="site-nav-toggle">
    <button aria-label="切换导航栏">
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>




<nav class="site-nav">
  
    <ul id="menu" class="menu">
      
        
        
        
          
          <li class="menu-item menu-item-home">
    <a href="/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-home"></i> <br />首页</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-about">
    <a href="/about/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-user"></i> <br />关于</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-tags">
    <a href="/tags/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />标签</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-categories">
    <a href="/categories/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-th"></i> <br />分类</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-archives">
    <a href="/archives/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />归档</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-commonweal">
    <a href="/404.html" rel="section">
      <i class="menu-item-icon fa fa-fw fa-heartbeat"></i> <br />公益 404</a>
  </li>

      
      
        <li class="menu-item menu-item-search">
          
            <a href="javascript:;" class="popup-trigger">
          
            
              <i class="menu-item-icon fa fa-search fa-fw"></i> <br />搜索</a>
        </li>
      
    </ul>
  

  
    

  

  
    <div class="site-search">
      
  
  <div class="algolia-popup popup search-popup">
    <div class="algolia-search">
      <div class="algolia-search-input-icon">
        <i class="fa fa-search"></i>
      </div>
      <div class="algolia-search-input" id="algolia-search-input"></div>
    </div>

    <div class="algolia-results">
      <div id="algolia-stats"></div>
      <div id="algolia-hits"></div>
      <div id="algolia-pagination" class="algolia-pagination"></div>
    </div>

    <span class="popup-btn-close">
      <i class="fa fa-times-circle"></i>
    </span>
  </div>




    </div>
  
</nav>



  



</div>
    </header>

    


    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  
    <div class="reading-progress-bar"></div>
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://wyu.space/2018/05/02/MySQL相关知识点/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="王宇">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Sometimes Naive">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">MySQL相关知识点
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">

            
            
            

            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              

              
                
              

              <time title="创建时间：2018-05-02 01:02:15 / 修改时间：23:36:38" itemprop="dateCreated datePublished" datetime="2018-05-02T01:02:15+08:00">2018-05-02</time>
            

            
              

              
            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing"><a href="/categories/MySQL/" itemprop="url" rel="index"><span itemprop="name">MySQL</span></a></span>

                
                
              
            </span>
          

          
            
          

          
          

          
            <span class="post-meta-divider">|</span>
            <span class="post-meta-item-icon"
            >
            <i class="fa fa-eye"></i>
             热度： 
            <span class="busuanzi-value" id="busuanzi_value_page_pv" ></span>
			<span>℃</span>
            </span>
          

          
            <div class="post-symbolscount">
              

              
                <span class="post-meta-item-icon">
                  <i class="fa fa-file-word-o"></i>
                </span>
                
                  <span class="post-meta-item-text">本文字数：</span>
                
                <span title="本文字数">4.1k</span>
              

              
                <span class="post-meta-divider">|</span>
              

              
                <span class="post-meta-item-icon">
                  <i class="fa fa-clock-o"></i>
                </span>
                
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                
                <span title="阅读时长">4 分钟</span>
              
            </div>
          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <h1 id="sql语句相关"><a href="#sql语句相关" class="headerlink" title="sql语句相关"></a>sql语句相关</h1><p>使用having过滤分组，使用where过滤行数据。集合操作使用having不使用where</p>
<p>%匹配0个或多个，_匹配单个</p>
<p>and 优先级大于 or</p>
<p>UNION并 </p>
<p>MINUS差 INTERSECT交 MYSQL不支持</p>
<p>UNION 内部的 SELECT 语句必须拥有相同数量的列。列也必须拥有相似的数据类型。同时，每条 SELECT 语句中的列的顺序必须相同。</p>
<p>允许重复 UNION ALL</p>
<p>拼接字段 mysql使用contact() oracle使用“||”和“+”</p>
<p>MySQL不支持top</p>
<p>limit要把前面所有的记录扫描出来截取需要的，如果id靠后费时间</p>
<h1 id="索引"><a href="#索引" class="headerlink" title="索引"></a>索引</h1><p>b树索引 </p>
<p>位图索引</p>
<h2 id="rowid"><a href="#rowid" class="headerlink" title="rowid"></a>rowid</h2><ol>
<li>rowid是18位大小写加数字混杂体，唯一表代该条记录在DBF文件中的位置</li>
<li>MySQL没有</li>
</ol>
<p>在定义primary key或unique约束后系统自动在相应的列上创建索引</p>
<h2 id="分类"><a href="#分类" class="headerlink" title="分类"></a>分类</h2><ol>
<li>唯一索引：唯一索引不允许两行具有相同的索引值</li>
<li>主键索引：为表定义一个主键将自动创建主键索引，主键索引是唯一索引的特殊类型。主键索引要求主键中的每个值是唯一的，并且不能为空</li>
<li>聚集索引(Clustered)：表中各行的物理顺序与键值的逻辑（索引）顺序相同，每个表只能有一个</li>
<li>非聚集索引(Non-clustered)：非聚集索引指定表的逻辑顺序。数据存储在一个位置，索引存储在另一个位置，索引中包含指向数据存储位置的指针。一个表上的可以有多个，小于249个</li>
</ol>
<h1 id="安全"><a href="#安全" class="headerlink" title="安全"></a>安全</h1><p>GRANT 和INVOKE管理</p>
<h1 id="触发器"><a href="#触发器" class="headerlink" title="触发器"></a>触发器</h1><p>触发器与单个表相连</p>
<p>在多表关联的视图上创建触发器</p>
<h1 id="锁"><a href="#锁" class="headerlink" title="锁"></a>锁</h1><p>MySQL：不同存储引擎支持不同锁机制</p>
<p>表级锁：开销小，加锁快；不会出现死锁；锁定粒度大，发生锁冲突的概率最高，并发度最低。<br>行级锁：开销大，加锁慢；会出现死锁；锁定粒度最小，发生锁冲突的概率最低，并发度也最高。<br>页面锁：开销和加锁时间界于表锁和行锁之间；会出现死锁；锁定粒度界于表锁和行锁之间，并发度一般</p>
<h2 id="MyISAM与INNODB"><a href="#MyISAM与INNODB" class="headerlink" title="MyISAM与INNODB"></a>MyISAM与INNODB</h2><h3 id="MyISAM"><a href="#MyISAM" class="headerlink" title="MyISAM"></a>MyISAM</h3><p>select 读锁</p>
<p>insert update delete 写锁</p>
<p>MyISAM支持并发锁（local）</p>
<p>读写争用，写锁获得锁</p>
<p>一定情况下，允许查询和插入并发执行</p>
<p>low-priority-updates降低优先级</p>
<h3 id="INNODB（支持事务、行级锁）"><a href="#INNODB（支持事务、行级锁）" class="headerlink" title="INNODB（支持事务、行级锁）"></a>INNODB（支持事务、行级锁）</h3><p>更新丢失（Lost Update）应用的问题，加锁解决</p>
<p>脏读（Dirty Reads）</p>
<p>不可重复读（Non-Repeatable Reads）</p>
<p>幻读（Phantom Reads） 都是读一致性问题</p>
<ol>
<li>加锁解决</li>
<li>提供时间点的版本快照（MVCC 多版本并发控制）</li>
</ol>
<p>未提交读（Read uncommitted） 最低级</p>
<p>已提交读（Read committed） 语句级</p>
<p>可重复读（Repeatable read） 事务级</p>
<p>可序列化（Serializable） 最高级别，事务级</p>
<p>共享锁 </p>
<p>排它锁</p>
<p>意向共享锁（先加意向锁）</p>
<p>意向排它锁</p>
<p>update delete insert 自动加排它锁</p>
<p>select 不加锁</p>
<p>select … for update 排它锁</p>
<p>select … lock in share mode 共享锁</p>
<p>对一个表而言，尽可能以固定的顺序存取表中的行。这样可以大减少死锁的机会。</p>
<p>只有通过索引条件检索数据，innodb才会使用行级锁，否则使用表锁。</p>
<p>范围查找不存在的加间隙锁（Next-Key锁）不使用间隙锁会发生幻读 </p>
<p>造成锁等待</p>
<p>绝大部分情况下使用行级锁（选择innodb的理由）</p>
<p>lock tables 加表锁 </p>
<p>表锁 MySQL Server层管理，autocommit设为0 否则不加锁。</p>
<p>先commit 再 unlock tables；</p>
<p>MYISAM锁一次获得，不会产生死锁，INNODB逐步获得，发生死锁 设置innodb_lock_wait_timeout</p>
<p>事务中要更新记录，直接申请排它锁 </p>
<p>在REPEATEABLE-READ隔离级别下，如果两个线程同时对相同条件记录用SELECT…ROR UPDATE加排他锁，在没有符合该记录情况下，两个线程都会加锁成功。程序发现记录尚不存在，就试图插入一条新记录，如果两个线程都这么做，就会出现死锁。这种情况下，将隔离级别改成READ COMMITTED，就可以避免问题。</p>
<p>当隔离级别为READ COMMITED时，如果两个线程都先执行SELECT…FOR UPDATE，判断是否存在符合条件的记录，如果没有，就插入记录。此时，只有一个线程能插入成功，另一个线程会出现锁等待，当第１个线程提交后，第２个线程会因主键重出错，但虽然这个线程出错了，却会获得一个排他锁！这时如果有第３个线程又来申请排他锁，也会出现死锁。对于这种情况，可以直接做插入操作，然后再捕获主键重异常，或者在遇到主键重错误时，总是执行ROLLBACK释放获得的排他锁。</p>
<h2 id="悲观锁"><a href="#悲观锁" class="headerlink" title="悲观锁"></a>悲观锁</h2><p>在查询完数据的时候就把事务锁起来，直到提交事务</p>
<p>select … for update;</p>
<h2 id="乐观锁"><a href="#乐观锁" class="headerlink" title="乐观锁"></a>乐观锁</h2><p>在修改数据的时候把事务锁起来，通过version的方式来进行锁定</p>
<p>update … set … , version = version + 1 where … and version= …;</p>
<h1 id="约束"><a href="#约束" class="headerlink" title="约束"></a>约束</h1><h2 id="主键（不支持非主键聚集索引）"><a href="#主键（不支持非主键聚集索引）" class="headerlink" title="主键（不支持非主键聚集索引）"></a>主键（不支持非主键聚集索引）</h2><p>也是用于控件字段内容不能重复，但它在一个表只允许出现一个。</p>
<h2 id="Unipqu约束"><a href="#Unipqu约束" class="headerlink" title="Unipqu约束"></a>Unipqu约束</h2><p>控件字段内容不能重复，一个表允许有多个 Unique 约束。</p>
<h2 id="Check约束"><a href="#Check约束" class="headerlink" title="Check约束"></a>Check约束</h2><p>用于控制字段的值范围。</p>
<h2 id="外键约束"><a href="#外键约束" class="headerlink" title="外键约束"></a>外键约束</h2><p>用于预防破坏表之间连接的动作，也能防止非法数据插入外键列，因为它必须是它指向的那个表中的值之一。</p>
<h2 id="不能为空约束"><a href="#不能为空约束" class="headerlink" title="不能为空约束"></a>不能为空约束</h2><p>用于控制字段的内容一定不能为空（NULL）</p>
<h1 id="范式"><a href="#范式" class="headerlink" title="范式"></a>范式</h1><h2 id="第一范式"><a href="#第一范式" class="headerlink" title="第一范式"></a>第一范式</h2><p>第一范式：字段是最小的的单元不可再分</p>
<h2 id="第二范式"><a href="#第二范式" class="headerlink" title="第二范式"></a>第二范式</h2><p>满足第一范式,表中的字段必须完全依赖于全部主键而非部分主键。</p>
<h2 id="第三范式"><a href="#第三范式" class="headerlink" title="第三范式"></a>第三范式</h2><p>满足第二范式，非主键外的所有字段必须互不依赖</p>
<h1 id="视图"><a href="#视图" class="headerlink" title="视图"></a>视图</h1><p>向视图提供数据内容的语句为 SELECT 语句,可以将视图理解为存储起来的 SELECT 语句</p>
<p>不提高效率。</p>
<h1 id="语言分类"><a href="#语言分类" class="headerlink" title="语言分类"></a>语言分类</h1><h2 id="DML-数据操纵语言"><a href="#DML-数据操纵语言" class="headerlink" title="DML 数据操纵语言"></a>DML 数据操纵语言</h2><p>select update insert delete</p>
<h2 id="DDL-数据库定义语言"><a href="#DDL-数据库定义语言" class="headerlink" title="DDL 数据库定义语言"></a>DDL 数据库定义语言</h2><p>create alter drop</p>
<h2 id="DCL-数据库控制语言"><a href="#DCL-数据库控制语言" class="headerlink" title="DCL 数据库控制语言"></a>DCL 数据库控制语言</h2><p>grant deny revoke</p>
<h2 id="delete-drop-truncate-区别"><a href="#delete-drop-truncate-区别" class="headerlink" title="delete drop truncate 区别"></a>delete drop truncate 区别</h2><p>delete逐行删除，删除速度慢</p>
<h1 id="超键、候选键、主键、外键"><a href="#超键、候选键、主键、外键" class="headerlink" title="超键、候选键、主键、外键"></a>超键、候选键、主键、外键</h1><h2 id="超键"><a href="#超键" class="headerlink" title="超键"></a>超键</h2><p>在关系中能唯一标识元组的属性集称为关系模式的超键</p>
<h2 id="候选键"><a href="#候选键" class="headerlink" title="候选键"></a>候选键</h2><p>是最小超键，即没有冗余元素的超键。</p>
<h2 id="主键"><a href="#主键" class="headerlink" title="主键"></a>主键</h2><p>数据库表中对储存数据对象予以唯一和完整标识的数据列或属性的组合</p>
<h2 id="外键"><a href="#外键" class="headerlink" title="外键"></a>外键</h2><p>在一个表中存在的另一个表的主键称此表的外键。</p>
<h1 id="防止丢失"><a href="#防止丢失" class="headerlink" title="防止丢失"></a>防止丢失</h1><p>archivelog mode(归档模式)只要其归档日志文件不丢失，就可以有效地防止数据丢失。</p>
<h1 id="MyIASM和Innodb两种引擎所使用的索引的数据结构是什么？"><a href="#MyIASM和Innodb两种引擎所使用的索引的数据结构是什么？" class="headerlink" title="MyIASM和Innodb两种引擎所使用的索引的数据结构是什么？"></a>MyIASM和Innodb两种引擎所使用的索引的数据结构是什么？</h1><p>都是B+树!</p>
<p>MyIASM引擎，B+树的数据结构中存储的内容实际上是实际数据的地址值。也就是说它的索引和实际数据是分开的，只不过使用索引指向了实际数据。这种索引的模式被称为非聚集索引。</p>
<p>Innodb引擎的索引的数据结构也是B+树，只不过数据结构中存储的都是实际的数据，这种索引有被称为聚集索引。</p>
<h1 id="varchar和char的区别"><a href="#varchar和char的区别" class="headerlink" title="varchar和char的区别"></a>varchar和char的区别</h1><p>Char是一种固定长度的类型，varchar是一种可变长度的类型</p>
<h1 id="mysql有关权限的表都有哪几个"><a href="#mysql有关权限的表都有哪几个" class="headerlink" title="mysql有关权限的表都有哪几个"></a>mysql有关权限的表都有哪几个</h1><p>权限表存放在mysql数据库里，由mysql_install_db脚本初始化</p>
<ol>
<li>user权限表：记录允许连接到服务器的用户帐号信息，里面的权限是全局级的。</li>
<li>db权限表：记录各个帐号在各个数据库上的操作权限。</li>
<li>table_priv权限表：记录数据表级的操作权限。</li>
<li>columns_priv权限表：记录数据列级的操作权限。</li>
<li>host权限表：配合db权限表对给定主机上数据库级操作权限作更细致的控制。这个权限表不受GRANT和REVOKE语句的影响。</li>
</ol>
<h1 id="数据表修复（MyISAM）"><a href="#数据表修复（MyISAM）" class="headerlink" title="数据表修复（MyISAM）"></a>数据表修复（MyISAM）</h1><p>使用 myisamchk 来修复</p>
<ol>
<li>修复前将mysql服务停止。</li>
<li>打开命令行方式，然后进入到mysql的/bin目录。</li>
<li>执行myisamchk –recover 数据库所在路径/*.MYI</li>
</ol>
<p>REPAIR TABLE 用于修复被破坏的表。<br>OPTIMIZE TABLE 用于回收闲置的数据库空间，当表上的数据行被删除时，所占据的磁盘空间并没有立即被回收，使用了OPTIMIZE TABLE命令后这些空间将被回收，并且对磁盘上的数据行进行重排（注意：是磁盘上，而非数据库）</p>
<h1 id="优化"><a href="#优化" class="headerlink" title="优化"></a>优化</h1><h2 id="选择最有效率的表名顺序"><a href="#选择最有效率的表名顺序" class="headerlink" title="选择最有效率的表名顺序"></a>选择最有效率的表名顺序</h2><p>数据库的解析器按照从右到左的顺序处理FROM子句中的表名，FROM子句中写在最后的表将被最先处理<br>在FROM子句中包含多个表的情况下：</p>
<ol>
<li><p>如果三个表是完全无关系的话，将记录和列名最少的表，写在最后，然后依次类推<br>也就是说：选择记录条数最少的表放在最后</p>
</li>
<li><p>如果有3个以上的表连接查询：<br>如果三个表是有关系的话，将引用最多的表，放在最后，然后依次类推。<br>也就是说：被其他表所引用的表放在最后</p>
</li>
</ol>
<h2 id="WHERE子句中的连接顺序"><a href="#WHERE子句中的连接顺序" class="headerlink" title="WHERE子句中的连接顺序"></a>WHERE子句中的连接顺序</h2><p>表之间的连接必须写在其他WHERE条件之左,那些可以过滤掉最大数量记录的条件必须写在WHERE子句的之右。</p>
<h2 id="SELECT子句中避免使用-号"><a href="#SELECT子句中避免使用-号" class="headerlink" title="SELECT子句中避免使用*号"></a>SELECT子句中避免使用*号</h2><h2 id="用TRUNCATE替代DELETE"><a href="#用TRUNCATE替代DELETE" class="headerlink" title="用TRUNCATE替代DELETE"></a>用TRUNCATE替代DELETE</h2><p>删除表的全部记录，除了表结构才这样做。</p>
<h2 id="多使用内部函数提高SQL效率"><a href="#多使用内部函数提高SQL效率" class="headerlink" title="多使用内部函数提高SQL效率"></a>多使用内部函数提高SQL效率</h2><p>使用mysql的concat()函数会比使用||来进行拼接快，因为concat()函数已经被mysql优化过了。</p>
<h2 id="使用表或列的别名"><a href="#使用表或列的别名" class="headerlink" title="使用表或列的别名"></a>使用表或列的别名</h2><p>如果表或列的名称太长了，使用一些简短的别名也能稍微提高一些SQL的性能。要扫描的字符长度就变少了</p>
<h2 id="多使用commit"><a href="#多使用commit" class="headerlink" title="多使用commit"></a>多使用commit</h2><p>释放回滚点</p>
<h2 id="索引-1"><a href="#索引-1" class="headerlink" title="索引"></a>索引</h2><h2 id="SQL写大写（Oracle）"><a href="#SQL写大写（Oracle）" class="headerlink" title="SQL写大写（Oracle）"></a>SQL写大写（Oracle）</h2><h2 id="避免在索引列上使用NOT（全表扫描）"><a href="#避免在索引列上使用NOT（全表扫描）" class="headerlink" title="避免在索引列上使用NOT（全表扫描）"></a>避免在索引列上使用NOT（全表扫描）</h2><h2 id="避免在索引列上使用计算（全表扫描）"><a href="#避免在索引列上使用计算（全表扫描）" class="headerlink" title="避免在索引列上使用计算（全表扫描）"></a>避免在索引列上使用计算（全表扫描）</h2><h2 id="用-gt-替代-gt-（低效）"><a href="#用-gt-替代-gt-（低效）" class="headerlink" title="用 &gt;= 替代 &gt;（低效）"></a>用 &gt;= 替代 &gt;（低效）</h2><h2 id="用IN替代OR"><a href="#用IN替代OR" class="headerlink" title="用IN替代OR"></a>用IN替代OR</h2><h2 id="总是使用索引的第一个列"><a href="#总是使用索引的第一个列" class="headerlink" title="总是使用索引的第一个列"></a>总是使用索引的第一个列</h2>
      
    </div>

    
	
	<div>
      
      <div>
    
        <div style="text-align:center;color: #ccc;font-size:14px;">-------------本文结束<i class="fa fa-paw"></i>感谢您的阅读-------------</div>
    
</div>
      
    </div>

    
    
    
	
    

    
      <div>
        <div style="padding: 10px 0; margin: 20px auto; width: 90%; text-align: center;">
  <div>坚持原创技术分享，您的支持将鼓励我继续创作！</div>
  <button id="rewardButton" disable="enable" onclick="var qr = document.getElementById('QR'); if (qr.style.display === 'none') {qr.style.display='block';} else {qr.style.display='none'}">
    <span>打赏</span>
  </button>
  <div id="QR" style="display: none;">

    
      <div id="wechat" style="display: inline-block">
        <img id="wechat_qr" src="/images/wechatpay.jpg" alt="王宇 微信支付"/>
        <p>微信支付</p>
      </div>
    

    
      <div id="alipay" style="display: inline-block">
        <img id="alipay_qr" src="/images/alipay.jpg" alt="王宇 支付宝"/>
        <p>支付宝</p>
      </div>
    

    

  </div>
</div>

      </div>
    

    
      <div>
        <ul class="post-copyright">
  <li class="post-copyright-author">
    <strong>本文作者： </strong>王宇</li>
  <li class="post-copyright-link">
    <strong>本文链接：</strong>
    <a href="http://wyu.space/2018/05/02/MySQL相关知识点/" title="MySQL相关知识点">http://wyu.space/2018/05/02/MySQL相关知识点/</a>
  </li>
  <li class="post-copyright-license">
    <strong>版权声明： </strong>本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" rel="external nofollow" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明出处！</li>
</ul>

      </div>
    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/知识点/" rel="tag"><i class="fa fa-tag"></i> 知识点</a>
          
            <a href="/tags/MySQL/" rel="tag"><i class="fa fa-tag"></i> MySQL</a>
          
        </div>
      

      
      
        <div class="post-widgets">
        

        

        
          
          <div id="needsharebutton-postbottom">
            <span class="btn">
              <i class="fa fa-share-alt" aria-hidden="true"></i>
            </span>
          </div>
        
        </div>
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2017/08/25/Spring Bean的加载过程/" rel="next" title="Spring Bean的加载过程">
                <i class="fa fa-chevron-left"></i> Spring Bean的加载过程
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2018/05/02/Java相关知识点/" rel="prev" title="Java相关知识点">
                Java相关知识点 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          

  
    <div class="comments" id="comments">
      <div id="lv-container" data-id="city" data-uid="MTAyMC8zNjE0NS8xMjY4MA=="></div>
    </div>

  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <img class="site-author-image" itemprop="image"
                src="/images/avatar.jpg"
                alt="王宇" />
            
              <p class="site-author-name" itemprop="name">王宇</p>
              <p class="site-description motion-element" itemprop="description"></p>
          </div>

          
            <nav class="site-state motion-element">
              
                <div class="site-state-item site-state-posts">
                
                  <a href="/archives/">
                
                    <span class="site-state-item-count">10</span>
                    <span class="site-state-item-name">日志</span>
                  </a>
                </div>
              

              
                
                
                <div class="site-state-item site-state-categories">
                  <a href="/categories/index.html">
                    
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                    <span class="site-state-item-count">7</span>
                    <span class="site-state-item-name">分类</span>
                  </a>
                </div>
              

              
                
                
                <div class="site-state-item site-state-tags">
                  <a href="/tags/index.html">
                    
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                    <span class="site-state-item-count">18</span>
                    <span class="site-state-item-name">标签</span>
                  </a>
                </div>
              
            </nav>
          

          
            <div class="feed-link motion-element">
              <a href="/atom.xml" rel="alternate">
                <i class="fa fa-rss"></i>
                RSS
              </a>
            </div>
          

          

          
          

          
          
            <div class="links-of-blogroll motion-element links-of-blogroll-block">
              <div class="links-of-blogroll-title">
                <i class="fa  fa-fw fa-link"></i>
                友情链接
              </div>
              <ul class="links-of-blogroll-list">
                
                  <li class="links-of-blogroll-item">
                    <a href="http://wangshifu.net.cn" title="Wong" target="_blank">Wong</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="http://pvitlzp.cn" title="刘志鹏" target="_blank">刘志鹏</a>
                  </li>
                
              </ul>
            </div>
          

          
            
          
          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#sql语句相关"><span class="nav-number">1.</span> <span class="nav-text">sql语句相关</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#索引"><span class="nav-number">2.</span> <span class="nav-text">索引</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#rowid"><span class="nav-number">2.1.</span> <span class="nav-text">rowid</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#分类"><span class="nav-number">2.2.</span> <span class="nav-text">分类</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#安全"><span class="nav-number">3.</span> <span class="nav-text">安全</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#触发器"><span class="nav-number">4.</span> <span class="nav-text">触发器</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#锁"><span class="nav-number">5.</span> <span class="nav-text">锁</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#MyISAM与INNODB"><span class="nav-number">5.1.</span> <span class="nav-text">MyISAM与INNODB</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#MyISAM"><span class="nav-number">5.1.1.</span> <span class="nav-text">MyISAM</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#INNODB（支持事务、行级锁）"><span class="nav-number">5.1.2.</span> <span class="nav-text">INNODB（支持事务、行级锁）</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#悲观锁"><span class="nav-number">5.2.</span> <span class="nav-text">悲观锁</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#乐观锁"><span class="nav-number">5.3.</span> <span class="nav-text">乐观锁</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#约束"><span class="nav-number">6.</span> <span class="nav-text">约束</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#主键（不支持非主键聚集索引）"><span class="nav-number">6.1.</span> <span class="nav-text">主键（不支持非主键聚集索引）</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Unipqu约束"><span class="nav-number">6.2.</span> <span class="nav-text">Unipqu约束</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Check约束"><span class="nav-number">6.3.</span> <span class="nav-text">Check约束</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#外键约束"><span class="nav-number">6.4.</span> <span class="nav-text">外键约束</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#不能为空约束"><span class="nav-number">6.5.</span> <span class="nav-text">不能为空约束</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#范式"><span class="nav-number">7.</span> <span class="nav-text">范式</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#第一范式"><span class="nav-number">7.1.</span> <span class="nav-text">第一范式</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#第二范式"><span class="nav-number">7.2.</span> <span class="nav-text">第二范式</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#第三范式"><span class="nav-number">7.3.</span> <span class="nav-text">第三范式</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#视图"><span class="nav-number">8.</span> <span class="nav-text">视图</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#语言分类"><span class="nav-number">9.</span> <span class="nav-text">语言分类</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#DML-数据操纵语言"><span class="nav-number">9.1.</span> <span class="nav-text">DML 数据操纵语言</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#DDL-数据库定义语言"><span class="nav-number">9.2.</span> <span class="nav-text">DDL 数据库定义语言</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#DCL-数据库控制语言"><span class="nav-number">9.3.</span> <span class="nav-text">DCL 数据库控制语言</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#delete-drop-truncate-区别"><span class="nav-number">9.4.</span> <span class="nav-text">delete drop truncate 区别</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#超键、候选键、主键、外键"><span class="nav-number">10.</span> <span class="nav-text">超键、候选键、主键、外键</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#超键"><span class="nav-number">10.1.</span> <span class="nav-text">超键</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#候选键"><span class="nav-number">10.2.</span> <span class="nav-text">候选键</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#主键"><span class="nav-number">10.3.</span> <span class="nav-text">主键</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#外键"><span class="nav-number">10.4.</span> <span class="nav-text">外键</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#防止丢失"><span class="nav-number">11.</span> <span class="nav-text">防止丢失</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#MyIASM和Innodb两种引擎所使用的索引的数据结构是什么？"><span class="nav-number">12.</span> <span class="nav-text">MyIASM和Innodb两种引擎所使用的索引的数据结构是什么？</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#varchar和char的区别"><span class="nav-number">13.</span> <span class="nav-text">varchar和char的区别</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#mysql有关权限的表都有哪几个"><span class="nav-number">14.</span> <span class="nav-text">mysql有关权限的表都有哪几个</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#数据表修复（MyISAM）"><span class="nav-number">15.</span> <span class="nav-text">数据表修复（MyISAM）</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#优化"><span class="nav-number">16.</span> <span class="nav-text">优化</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#选择最有效率的表名顺序"><span class="nav-number">16.1.</span> <span class="nav-text">选择最有效率的表名顺序</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#WHERE子句中的连接顺序"><span class="nav-number">16.2.</span> <span class="nav-text">WHERE子句中的连接顺序</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#SELECT子句中避免使用-号"><span class="nav-number">16.3.</span> <span class="nav-text">SELECT子句中避免使用*号</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#用TRUNCATE替代DELETE"><span class="nav-number">16.4.</span> <span class="nav-text">用TRUNCATE替代DELETE</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#多使用内部函数提高SQL效率"><span class="nav-number">16.5.</span> <span class="nav-text">多使用内部函数提高SQL效率</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#使用表或列的别名"><span class="nav-number">16.6.</span> <span class="nav-text">使用表或列的别名</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#多使用commit"><span class="nav-number">16.7.</span> <span class="nav-text">多使用commit</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#索引-1"><span class="nav-number">16.8.</span> <span class="nav-text">索引</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#SQL写大写（Oracle）"><span class="nav-number">16.9.</span> <span class="nav-text">SQL写大写（Oracle）</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#避免在索引列上使用NOT（全表扫描）"><span class="nav-number">16.10.</span> <span class="nav-text">避免在索引列上使用NOT（全表扫描）</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#避免在索引列上使用计算（全表扫描）"><span class="nav-number">16.11.</span> <span class="nav-text">避免在索引列上使用计算（全表扫描）</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#用-gt-替代-gt-（低效）"><span class="nav-number">16.12.</span> <span class="nav-text">用 >= 替代 >（低效）</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#用IN替代OR"><span class="nav-number">16.13.</span> <span class="nav-text">用IN替代OR</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#总是使用索引的第一个列"><span class="nav-number">16.14.</span> <span class="nav-text">总是使用索引的第一个列</span></a></li></ol></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>

<div class="copyright">&copy; 2017 &mdash; <span itemprop="copyrightYear">2018</span>
  <span class="with-love" id="animate">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">王宇</span>

  
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-area-chart"></i>
    </span>
    
      <span class="post-meta-item-text">站点总字数：</span>
    
    <span title="站点总字数">29k</span>
  

  
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-coffee"></i>
    </span>
    
      <span class="post-meta-item-text">站点阅读时长 &asymp;</span>
    
    <span title="站点阅读时长">26 分钟</span>
  
</div>




  <div class="powered-by">由 <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a> 强力驱动 v3.3.8</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">主题 &mdash; <a class="theme-link" target="_blank" href="https://github.com/theme-next/hexo-theme-next">NexT.Mist</a> v6.2.0</div>



        
<div class="busuanzi-count">
  <script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>

  
    <span class="site-uv" title="总访客量">
      <i class="fa fa-user"></i>
      <span class="busuanzi-value" id="busuanzi_value_site_uv"></span>
    </span>
  

  
    <span class="site-pv" title="总访问量">
      <i class="fa fa-eye"></i>
      <span class="busuanzi-value" id="busuanzi_value_site_pv"></span>
    </span>
  
</div>









        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    
      <div id="needsharebutton-float">
        <span class="btn">
          <i class="fa fa-share-alt" aria-hidden="true"></i>
        </span>
      </div>
    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>














  











  



  
  
    <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/canvas-nest/canvas-nest.min.js"></script>
  

  
  
    <script type="text/javascript" src="/lib/reading_progress/reading_progress.js"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v=6.2.0"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=6.2.0"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=6.2.0"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=6.2.0"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=6.2.0"></script>



  



	





  





  
    <script type="text/javascript">
      (function(d, s) {
        var j, e = d.getElementsByTagName(s)[0];
        if (typeof LivereTower === 'function') { return; }
        j = d.createElement(s);
        j.src = 'https://cdn-city.livere.com/js/embed.dist.js';
        j.async = true;
        e.parentNode.insertBefore(j, e);
      })(document, 'script');
    </script>
  










  




  
  
  
  <link rel="stylesheet" href="/lib/algolia-instant-search/instantsearch.min.css">

  
  
  <script src="/lib/algolia-instant-search/instantsearch.min.js"></script>
  

  <script src="/js/src/algolia-search.js?v=6.2.0"></script>



  

  

  
<script>
(function(){
    var bp = document.createElement('script');
    var curProtocol = window.location.protocol.split(':')[0];
    if (curProtocol === 'https') {
        bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';        
    }
    else {
        bp.src = 'http://push.zhanzhang.baidu.com/push.js';
    }
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(bp, s);
})();
</script>


  

  
  
  
  <script src="/lib/needsharebutton/needsharebutton.js"></script>

  <script>
    
      pbOptions = {};
      
          pbOptions.iconStyle = "box";
      
          pbOptions.boxForm = "horizontal";
      
          pbOptions.position = "bottomCenter";
      
          pbOptions.networks = "Weibo,Wechat,Douban,QQZone,Twitter,Facebook";
      
      new needShareButton('#needsharebutton-postbottom', pbOptions);
    
    
      flOptions = {};
      
          flOptions.iconStyle = "box";
      
          flOptions.boxForm = "horizontal";
      
          flOptions.position = "bottomLeft";
      
          flOptions.networks = "Weibo,Wechat,Douban,QQZone,Twitter,Facebook";
      
      new needShareButton('#needsharebutton-float', flOptions);
    
  </script>

  

  

  

  

  
  
  
  <script src="/lib/bookmark/bookmark.min.js?v=1.0"></script>
  <script type="text/javascript">
  
    bookmark.scrollToMark('auto', "#更多");
  
  </script>


  

  
  <!-- 页面点击小红心 -->
  <script type="text/javascript" src="/js/src/love.js"></script>
</body>
</html>
